package com.doucat.support.component.recycle.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.doucat.support.component.recycle.holder.BaseRecyclerHolder;
import com.doucat.support.component.recycle.holder.ItemRecyclerHolder;

import java.util.List;

/**
 * -----------------------------------------------------------------
 * Copyright (C) 2014-2016, by your company, All rights reserved.
 * -----------------------------------------------------------------
 * File: CommonRecyclerAdapter.java
 * Author: wfy
 * Version: V100R001C01
 * Create: 2020/6/2 17:35
 * Changes (from 2020/6/2)
 * -----------------------------------------------------------------
 * 2020/6/2 : Create DuoRecyclerAdapter.java (win7);
 * -----------------------------------------------------------------
 */
public abstract class CommonRecyclerAdapter<T> extends BaseRecyclerAdapter<T>{
    protected String TAG=getClass().getSimpleName();
    //普通布局的type
    public static final int TYPE_ITEM = 1;
    public CommonRecyclerAdapter(Context context, List<T> data) {
        super(context, data);
    }

    public CommonRecyclerAdapter(Context context) {
        super(context);
    }

    @Override
    public int getItemCount() {
        int count = items != null ? items.size() : 0;
        return count;
    }

    @Override
    public BaseRecyclerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(getLayoutRes(),parent,false);
        BaseRecyclerHolder holder = new ItemRecyclerHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(BaseRecyclerHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        onBindItemViewHolder(holder,position);
    }

    protected abstract void onBindItemViewHolder(BaseRecyclerHolder holder, int position);

    public void destroy(){

    }
}
